import React from "react";

class co extends React.Component {
  constructor(props){
    super(props)
    this.state={
      age:18
    }

  }
  //父组件调用子组件的方法
  childrenMethod=()=> {
    alert("调用子组件方法");
  }
  //子组件调用父组件的方法
  change=()=>{
    console.log('123')
    this.props.callback('1',2,this.state.age);
}

  render() {
  return <div>我是子组件{this.props.name}
  <button onClick={this.change}>子组件中调用父组件</button>
  </div>;
  }
}

export default co;
